<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<jsp:include page="/WEB-INF/backstage/util.jsp" />
</head>
<body>
	<center>
		<div style="height:40px;background-color: white;"  data-options="region:'north',split:false">
       			<table align="left" class="searchContent" style="font-weight: bold;font-size: 15px">
					<tr>
						<td colspan="2">
							<!-- 添加按钮 -->
							<button style="background:#1E90FF; font-weight: bold;font-size: 15px" class="glyphicon glyphicon-plus btn-sm"  data-toggle="modal" data-target="#myModal" onclick="toadd()">添加</button>
							<!-- 颜值配置按钮 -->
							<button type="button" style="background:#1E90FF; font-weight: bold;font-size: 15px" class="glyphicon glyphicon-cog btn-sm"  onclick="allocation()">颜值配置</button>
						</td>
					</tr>
				</table>
		</div>
		<!-- 查询所有 -->
		<form action="" method="post" id="form">
			<table id="dataList" class="table table-hover" border="1" style="font-weight: bold;font-size: 15px">
					<tr>
						<td></td>
						<td>购买颜值数量</td>
						<td>赠送颜值数量</td>
						<td>备注</td>
						<td>创建时间</td>
						<td>修改时间</td>
						<td>操作</td>
					</tr>
					<c:forEach items="${BBCList }" var="BBC">
						<tr >
							<td>${BBC.config_id }</td>
							<td>${BBC.buy_num }</td>
							<td>${BBC.give_num }</td>
							<td>${BBC.remark }</td>
							<td><f:formatDate value="${BBC.create_time }" pattern="yyyy-MM-dd"/></td>
							<td><f:formatDate value="${BBC.modify_time }" pattern="yyyy-MM-dd"/></td>
							<td><button type="button" style="background:#1E90FF; font-weight: bold;font-size: 15px" class="btn btn-default btn-xs glyphicon glyphicon-pencil" onclick="querybeautybyid(${BBC.config_id})" data-toggle="modal" data-target="#myModal">修改</button>
					 		<button type="button" style="background:#1E90FF; font-weight: bold;font-size: 15px" class="btn btn-default btn-xs glyphicon glyphicon-remove" onclick="del(${BBC.config_id})">删除</button></td>
						</tr>
					</c:forEach>
			</table>
			
		</form>
		<!-- 查询所有结束 -->
		<!-- Modal -->
		<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static">
		  <div class="modal-dialog">
		    <div class="modal-content">
		      <div class="modal-header">
		        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
		        <h4 align="left" class="modal-title" id="myModalLabel" style="font-weight: bolder">更新颜值配置信息</h4>
		      </div>
		      <div class="modal-body">
		       <form action="${pageContext.request.contextPath }/wsyconfig/updateBis_beauty_config" method="post" id="Myform" class="form-horizontal">
		       	<div class="form-group">
				    <input type="hidden" id="config_id" name="config_id" value="0"/>
				</div>
				<div class="form-group">
				    <label for="inputEmail3" class="col-sm-4 control-label">购买颜值数量：</label>
				    <div class="col-sm-8">
				      <input type ="number" min="0" max="10000000"  class="form-control" id="buy_num"  name="buy_num" value="${BBC.buy_num }">
				    </div>
				</div></br></br>
			 	<div class="form-group">
				    <label for="inputEmail3" class="col-sm-4 control-label">赠送颜值数量：</label>
				    <div class="col-sm-8">
				      <input type ="number" min="0" max="10000000" class="form-control" id="give_num" name="give_num" value="${BBC.give_num }">
					</div>
			    </div></br></br>
			    <div class="form-group">
				    <label for="inputEmail3" class="col-sm-4 control-label">备注：</label>
				    <div class="col-sm-8">
				      <textarea class="form-control" rows="2" name="remark" id="remark" value="${BBC.remark }"></textarea>
				    </div>
			    </div></br></br>
		      </div>
		      <div class="modal-footer">
		        <button type="button" class="glyphicon glyphicon-off" data-dismiss="modal">关闭</button>
		        <button type="submit" class="glyphicon glyphicon-ok" >保存</button>
		      </div>
		     </form>
		    </div>
		  </div>
		</div>
		<!-- 添加模态框结束 -->
		
		<!-- Modal -->
		<div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static">
		  <div class="modal-dialog">
		    <div class="modal-content">
		      <div class="modal-header">
		        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
		         <h4 class="modal-title" id="myModalLabel" align="left" style="font-weight: bold;">颜值配置</h4>
		      </div>
		      <div class="modal-body">
			<form  method="post" id="form2" action="${pageContext.request.contextPath }/wsyconfig/saveConfig">
		     	<div class="form-group" >
				    <label for="inputEmail3" class="col-sm-4 control-label">一元人名币可兑换：</label>
				    <div class="col-sm-6" >
				      <input type ="number" min="0" max="10000000"  class="form-control" id="beautyNum"  name="beautyNum" value="">
				    </div>
				    <label for="inputEmail3" class="col-sm-2 control-label">个颜值</label><br><br>
				</div><br>
				<div class="form-group" align="center">
				    <label for="inputPassword3" class="col-sm-4 control-label">颜值有效期</label>
				    <div class="col-sm-6">
				      <input type ="number" min="0" max="10000000"  class="form-control" id="hasDay"  name="hasDay" value="">
				    </div>
				    <label for="inputEmail3" class="col-sm-2 control-label">天</label><br><br>
			    </div>
		      </div>
		       <div class="modal-footer" align="center">
			        <button type="buton" class="glyphicon glyphicon-off" data-dismiss="modal">退出</button>
			        <button type="submit" class="glyphicon glyphicon-ok" onclick="baocun()">保存</button>
			   </div>
		     </form>
		    </div>
		  </div>
		</div>
		<!--颜值配置模态框结束 -->
	</center>
</body>
<script type="text/javascript">
	//颜值配置
	function allocation(){ 
		$.post("/bsc/wsyconfig/getDataFromRedis",function(msg){
			var data=msg.split(":");
			$("#myModal1").modal("show");
			$("#beautyNum").val(data[0]);
			$("#hasDay").val(data[1])
		});
	}
	function baocun(){
		$("#myModal1").modal("hide");
	    document.form2.submit();
	}
	//添加模态框清空
	function toadd(){
		$("#buy_num").val("");
		$("#give_num").val("");
		$("#remark").val("");
	}
	//删除
	function del(config_id){
		if(window.confirm("你确定要删除该颜值基本设置信息吗 ？")){
			document.forms[0].action="${pageContext.request.contextPath }/wsyconfig/deleteBis_beauty_config?id="+config_id; 
			document.forms[0].submit();
		}
	} 
	//修改
	function querybeautybyid(config_id){
 		$.ajax({
			type:"POST",
			url:"${pageContext.request.contextPath }/wsyconfig/findByConfig_idBis_beauty_config/"+config_id,
			dataType:"json",
			success: function(BBC){
				//alert(BBC.config_id);
				$("#config_id").val(BBC.config_id);
				$("#buy_num").val(BBC.buy_num);
				$("#give_num").val(BBC.give_num);
				$("#remark").val(BBC.remark); 
				$('#myModal').modal('show');
		   }
		});
	}	
	</script>
</html>
